import { Controller, Get } from '@nestjs/common';
import { Permission } from '@lib/db/models/permission.model';
import { InjectModel } from 'nestjs-typegoose';
import { ModelType } from '@typegoose/typegoose/lib/types';
import { ApiUseTags, ApiOkResponse } from '@nestjs/swagger';
import allPermission from '../config/permission'

@Controller('permission')
@ApiUseTags('权限列表')
export class PermissionController {
  private inited: boolean
  constructor(
    @InjectModel(Permission) private readonly model: ModelType<Permission>
  ) { }

  private async  initAllPermission() {
    console.log(allPermission)
    const data = await this.model.find()
    if (data.length !== 0) {
      this.inited = true
    } else {
      const res = await this.model.insertMany(allPermission)
      this.inited = true
      console.log(res.length)
    }
  }
}



